package com.scgk.sync.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.scgk.sync.common.BaseResponse;
import com.scgk.sync.doamin.MJTD;
import com.scgk.sync.mapper.MjtdMapper;
import com.scgk.sync.service.MjtdService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Api(value = "同步微服务对外提供的接口", tags = "同步微服务对外提供的接口")
@Slf4j
@RestController
@RequestMapping("/rkldfeign")
public class RkldFeignController {

    @Autowired
    private MjtdService mjtdService;

    @Autowired
    private MjtdMapper mjtdMapper;


    @ApiOperation("获取移动数据-测试使用")
    @PostMapping("/getRkldDataByCondition")
    public BaseResponse<String> getRkldDataByCondition(@RequestBody JSONObject object) {
        log.info("查询条件：{}", object);
        Integer pageNum = object.getInteger("pageNum");
        Integer pageSize = object.getInteger("pageSize");

        Page page = new Page(pageNum, pageSize);

        // todo 待添加查询条件
        Page<MJTD> mjtdPage = mjtdService.page(page, null);
        List<MJTD> records = mjtdPage.getRecords();
        String jsonString = JSONObject.toJSONString(records);
        log.info("数据同步微服务返回数据：{}", jsonString);
        return BaseResponse.ok(jsonString);
    }



}
